package com.mybatis.generator.config;

import com.mybatis.generator.utils.FileUtil;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

public class CodeGeneratorConfig {

    private String codeCommentsAuthor;  // 类注释作者
    private Date createDate = new Date();   // 类注释创建日期
    private String codeGeneratorPath;   // 代码生成路径
    private String templatePath;    // 模板所在路径
    private String classBasePackage;    // 类的包名
    private String tableNameReplaceChar = "";   // 根据表名生成类名中需要替除的字符串
    private String tableNameSeparator = "_";  // 表名分隔符

    /**
     * 实体配置
     */
    private String classPackageEntity = "bean";  // 实体类包名
    private String classPathEntity = "";         // 实体类存放路径
    private String classNameEntityPrefix = "";   // 实体类名前缀
    private String classNameEntitySuffix = "";   // 实体类名后缀
    private String templateFileNameEntity = "entity.ftl";   // 实体类文件模板名
    /**
     * DAO接口配置
     */
    private String classPackageDao = "dao"; // DAO接口包名
    private String classPathDao; // DAO接口存放路径
    private String classNameDaoPrefix = "I";
    private String classNameDaoSuffix = "Dao";
    private String templateFileNameDao = "dao.ftl";   // DAO接口文件模板名
    /**
     * DAO实现配置
     */
    private String classPackageDaoImpl = "dao.impl"; // DAO实现包名
    private String classPathDaoImpl = "";           // DAO实现存放路径
    private String classNameDaoImplPrefix = "";
    private String classNameDaoImplSuffix = "DaoImpl";
    private String templateFileNameDaoImpl = "daoImpl.ftl";   // DAO实现文件模板名
    /**
     * Mapper映射文件配置
     */
    private String classPathMapper = "\\resources\\mybatis\\";  // Mapper映射文件目录名
    private String classNameMapperPrefix = "";
    private String classNameMapperSuffix = "";
    private String templateFileNameMapper = "mapper.ftl";   // Mapper映射文件模板名
    /**
     * Service接口配置
     */
    private String classPackageService = "service";     // Service接口包名
    private String classPathService = "";               // Service接口存放路径
    private String classNameServicePrefix = "I";
    private String classNameServiceSuffix = "Service";
    private String templateFileNameService = "service.ftl";   // Service接口模板名
    /**
     * Service实现配置
     */
    private String classPackageServiceImpl = "service.impl";     // Service实现包名
    private String classPathServiceImpl = "";           // Service实现存放路径
    private String classNameServiceImplPrefix = "";
    private String classNameServiceImplSuffix = "ServiceImpl";
    private String templateFileNameServiceImpl = "serviceImpl.ftl";   // Service实现模板名
    /**
     * Controller配置
     */
    private String classPackageController = "controller";     // Controller包名
    private String classPathController = "";             // Controller存放路径
    private String classNameControllerPrefix = "";
    private String classNameControllerSuffix = "Controller";
    private String templateFileNameController = "controller.ftl";   // Controller模板名

    /**
     * 数据库配置
     */
    private String dbDriverClassName;   // 数据库连接类
    private String dbName;  // 数据库名称
    private String dbUrl;   // 数据库连接URL
    private String dbUserName;  // 数据库用户名
    private String dbUserPassword;  // 数据库密码

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public String getCodeCommentsAuthor() {
        return codeCommentsAuthor;
    }

    public void setCodeCommentsAuthor(String codeCommentsAuthor) {
        this.codeCommentsAuthor = codeCommentsAuthor;
    }

    public String getCodeGeneratorPath() {
        return codeGeneratorPath;
    }

    public void setCodeGeneratorPath(String codeGeneratorPath) {
        this.codeGeneratorPath = codeGeneratorPath;
    }

    public String getTemplatePath() {
        return templatePath;
    }

    public void setTemplatePath(String templatePath) {
        this.templatePath = templatePath;
    }

    public String getClassNameEntityPrefix() {
        return classNameEntityPrefix;
    }

    public String getClassNameEntitySuffix() {
        return classNameEntitySuffix;
    }

    public String getClassNameDaoPrefix() {
        return classNameDaoPrefix;
    }

    public String getClassNameDaoSuffix() {
        return classNameDaoSuffix;
    }

    public String getClassNameDaoImplPrefix() {
        return classNameDaoImplPrefix;
    }

    public String getClassNameDaoImplSuffix() {
        return classNameDaoImplSuffix;
    }

    public String getClassNameMapperPrefix() {
        return classNameMapperPrefix;
    }

    public String getClassNameMapperSuffix() {
        return classNameMapperSuffix;
    }

    public String getClassNameServicePrefix() {
        return classNameServicePrefix;
    }

    public String getClassNameServiceSuffix() {
        return classNameServiceSuffix;
    }

    public String getClassNameServiceImplPrefix() {
        return classNameServiceImplPrefix;
    }

    public String getClassNameServiceImplSuffix() {
        return classNameServiceImplSuffix;
    }

    public void setClassNameEntityPrefix(String classNameEntityPrefix) {
        this.classNameEntityPrefix = classNameEntityPrefix;
    }

    public void setClassNameEntitySuffix(String classNameEntitySuffix) {
        this.classNameEntitySuffix = classNameEntitySuffix;
    }

    public void setClassNameDaoPrefix(String classNameDaoPrefix) {
        this.classNameDaoPrefix = classNameDaoPrefix;
    }

    public void setClassNameDaoSuffix(String classNameDaoSuffix) {
        this.classNameDaoSuffix = classNameDaoSuffix;
    }

    public void setClassNameDaoImplPrefix(String classNameDaoImplPrefix) {
        this.classNameDaoImplPrefix = classNameDaoImplPrefix;
    }

    public void setClassNameDaoImplSuffix(String classNameDaoImplSuffix) {
        this.classNameDaoImplSuffix = classNameDaoImplSuffix;
    }

    public void setClassNameMapperPrefix(String classNameMapperPrefix) {
        this.classNameMapperPrefix = classNameMapperPrefix;
    }

    public void setClassNameMapperSuffix(String classNameMapperSuffix) {
        this.classNameMapperSuffix = classNameMapperSuffix;
    }

    public void setClassNameServicePrefix(String classNameServicePrefix) {
        this.classNameServicePrefix = classNameServicePrefix;
    }

    public void setClassNameServiceSuffix(String classNameServiceSuffix) {
        this.classNameServiceSuffix = classNameServiceSuffix;
    }

    public void setClassNameServiceImplPrefix(String classNameServiceImplPrefix) {
        this.classNameServiceImplPrefix = classNameServiceImplPrefix;
    }

    public void setClassNameServiceImplSuffix(String classNameServiceImplSuffix) {
        this.classNameServiceImplSuffix = classNameServiceImplSuffix;
    }

    public String getTemplateFileNameEntity() {
        return templateFileNameEntity;
    }

    public String getTemplateFileNameDao() {
        return templateFileNameDao;
    }

    public String getTemplateFileNameDaoImpl() {
        return templateFileNameDaoImpl;
    }

    public String getTemplateFileNameMapper() {
        return templateFileNameMapper;
    }

    public String getTemplateFileNameService() {
        return templateFileNameService;
    }

    public String getTemplateFileNameServiceImpl() {
        return templateFileNameServiceImpl;
    }

    public void setTemplateFileNameEntity(String templateFileNameEntity) {
        this.templateFileNameEntity = templateFileNameEntity;
    }

    public void setTemplateFileNameDao(String templateFileNameDao) {
        this.templateFileNameDao = templateFileNameDao;
    }

    public void setTemplateFileNameDaoImpl(String templateFileNameDaoImpl) {
        this.templateFileNameDaoImpl = templateFileNameDaoImpl;
    }

    public void setTemplateFileNameMapper(String templateFileNameMapper) {
        this.templateFileNameMapper = templateFileNameMapper;
    }

    public void setTemplateFileNameService(String templateFileNameService) {
        this.templateFileNameService = templateFileNameService;
    }

    public void setTemplateFileNameServiceImpl(String templateFileNameServiceImpl) {
        this.templateFileNameServiceImpl = templateFileNameServiceImpl;
    }

    public String getDbName() {
        return dbName;
    }

    public void setDbName(String dbName) {
        this.dbName = dbName;
    }

    public String getDbUrl() {
        return dbUrl;
    }

    public void setDbUrl(String dbUrl) {
        this.dbUrl = dbUrl;
    }

    public String getDbUserName() {
        return dbUserName;
    }

    public void setDbUserName(String dbUserName) {
        this.dbUserName = dbUserName;
    }

    public String getDbUserPassword() {
        return dbUserPassword;
    }

    public void setDbUserPassword(String dbUserPassword) {
        this.dbUserPassword = dbUserPassword;
    }

    public String getDbDriverClassName() {
        return dbDriverClassName;
    }

    public void setDbDriverClassName(String dbDriverClassName) {
        this.dbDriverClassName = dbDriverClassName;
    }

    public String getClassBasePackage() {
        return classBasePackage;
    }

    public void setClassBasePackage(String classBasePackage) {
        this.classBasePackage = classBasePackage;
    }

    public String getClassPackageEntity() {
        return classPackageEntity;
    }

    public void setClassPackageEntity(String classPackageEntity) {
        this.classPackageEntity = classPackageEntity;
    }

    public String getClassPackageDao() {
        return classPackageDao;
    }

    public void setClassPackageDao(String classPackageDao) {
        this.classPackageDao = classPackageDao;
    }

    public String getClassPackageDaoImpl() {
        return classPackageDaoImpl;
    }

    public void setClassPackageDaoImpl(String classPackageDaoImpl) {
        this.classPackageDaoImpl = classPackageDaoImpl;
    }

    public String getClassPackageService() {
        return classPackageService;
    }

    public void setClassPackageService(String classPackageService) {
        this.classPackageService = classPackageService;
    }

    public String getClassPackageServiceImpl() {
        return classPackageServiceImpl;
    }

    public void setClassPackageServiceImpl(String classPackageServiceImpl) {
        this.classPackageServiceImpl = classPackageServiceImpl;
    }

    public String getClassPathEntity() {
        if(StringUtils.isBlank(classPathEntity)) {
            classPathEntity = codeGeneratorPath + FileUtil.genFilePathByPackage(classBasePackage + "." + classPackageEntity) + "/";
        }
        return classPathEntity;
    }

    public void setClassPathEntity(String classPathEntity) {
        this.classPathEntity = classPathEntity;
    }

    public String getClassPathDao() {
        if(StringUtils.isBlank(classPathDao)) {
            classPathDao = codeGeneratorPath + FileUtil.genFilePathByPackage(classBasePackage + "." + classPackageDao) + "/";
        }
        return classPathDao;
    }

    public void setClassPathDao(String classPathDao) {
        this.classPathDao = classPathDao;
    }

    public String getClassPathDaoImpl() {
        if(StringUtils.isBlank(classPathDaoImpl)) {
            classPathDaoImpl = codeGeneratorPath + FileUtil.genFilePathByPackage(classBasePackage + "." + classPackageDaoImpl) + "/";
        }
        return classPathDaoImpl;
    }

    public void setClassPathDaoImpl(String classPathDaoImpl) {
        this.classPathDaoImpl = classPathDaoImpl;
    }

    public String getClassPathMapper() {
        return codeGeneratorPath + classPathMapper;
    }

    public void setClassPathMapper(String classPathMapper) {
        this.classPathMapper = classPathMapper;
    }

    public String getClassPathService() {
        if(StringUtils.isBlank(classPathService)) {
            classPathService = codeGeneratorPath + FileUtil.genFilePathByPackage(classBasePackage + "." + classPackageService) + "/";
        }
        return classPathService;
    }

    public void setClassPathService(String classPathService) {
        this.classPathService = classPathService;
    }

    public String getClassPathServiceImpl() {
        if(StringUtils.isBlank(classPathServiceImpl)) {
            classPathServiceImpl = codeGeneratorPath + FileUtil.genFilePathByPackage(classBasePackage + "." + classPackageServiceImpl) + "/";
        }
        return classPathServiceImpl;
    }

    public void setClassPathServiceImpl(String classPathServiceImpl) {
        this.classPathServiceImpl = classPathServiceImpl;
    }

    public String getClassNameControllerPrefix() {
        return classNameControllerPrefix;
    }

    public void setClassNameControllerPrefix(String classNameControllerPrefix) {
        this.classNameControllerPrefix = classNameControllerPrefix;
    }

    public String getClassNameControllerSuffix() {
        return classNameControllerSuffix;
    }

    public void setClassNameControllerSuffix(String classNameControllerSuffix) {
        this.classNameControllerSuffix = classNameControllerSuffix;
    }

    public String getTemplateFileNameController() {
        return templateFileNameController;
    }

    public void setTemplateFileNameController(String templateFileNameController) {
        this.templateFileNameController = templateFileNameController;
    }

    public String getClassPackageController() {
        return classPackageController;
    }

    public void setClassPackageController(String classPackageController) {
        this.classPackageController = classPackageController;
    }

    public String getClassPathController() {
        if(StringUtils.isBlank(classPathController)) {
            classPathController = codeGeneratorPath + FileUtil.genFilePathByPackage(classBasePackage + "." + classPackageController) + "/";
        }
        return classPathController;
    }

    public void setClassPathController(String classPathController) {
        this.classPathController = classPathController;
    }

    public String getTableNameReplaceChar() {
        return tableNameReplaceChar;
    }

    public void setTableNameReplaceChar(String tableNameReplaceChar) {
        this.tableNameReplaceChar = tableNameReplaceChar;
    }

    public String getTableNameSeparator() {
        return tableNameSeparator;
    }

    public void setTableNameSeparator(String tableNameSeparator) {
        this.tableNameSeparator = tableNameSeparator;
    }
}
